<template>
  <div class="example">
    <mobilenavHeader />

    <!-- 顶部横幅 -->
    <div class="example-banner">
      <div class="banner-content">
        <h1>创新数据治理，赋能行业转型</h1>
        <h3>多行业应用广，案例精，信息智能方案强展数字化风华</h3>
      </div>
    </div>

    <!-- 案例展示 -->
    <div class="example-content">
      <div class="cards-grid">
        <div
          v-for="(item, index) in exampleList"
          :key="index"
          class="example-card"
          @click="godetailPage(index + 1)"
        >
          <div class="card-image-wrapper">
            <van-image :src="item.path" fit="cover" class="card-image">
              <template #loading>
                <van-loading type="spinner" size="20" />
              </template>
              <template #error>
                <div class="error-block">
                  <van-icon name="photo-fail" size="20" />
                  <p>加载失败</p>
                </div>
              </template>
            </van-image>
            <div class="image-overlay">
              <h3 class="overlay-title">{{ item.title }}</h3>
              <p class="overlay-desc">{{ item.desc.split("，")[0] }}</p>
            </div>
          </div>
          <div class="card-content">
            <div class="card-title">【{{ item.title }}】</div>
            <div class="card-desc">{{ item.desc }}</div>
          </div>
        </div>
      </div>
    </div>

    <back-top />
    <mobilebottom :backColor="'#f3f3f6'" />
  </div>
</template>

<script setup lang="ts">
import { ref, reactive } from "vue";
import { useRouter } from "vue-router";
import mobilenavHeader from "@/components/mobilenavHeader.vue";
import mobilebottom from "@/components/mobilebottom.vue";
import BackTop from "@/components/BackTop.vue";

// 导入图片
import kq from "@/assets/img/example/hrkq.png";
import ai from "@/assets/img/example/aizs.png";
import sj from "@/assets/img/example/jtsj.png";
import cj from "@/assets/img/example/sjcj.png";
import zsj from "@/assets/img/example/sjgl.png";
import qx from "@/assets/img/example/sjqx.png";

const router = useRouter();

const exampleList = reactive([
  {
    path: cj,
    title: "渠道数据采集",
    desc: "多渠道数据汇聚，精准采集助力决策",
  },
  {
    path: zsj,
    title: "主数据管理",
    desc: "统一主数据管理，提升数据准确性",
  },
  {
    path: qx,
    title: "渠道数据清洗",
    desc: "智能清洗渠道数据，确保数据纯净高效",
  },
  {
    path: ai,
    title: "企业AI助手",
    desc: "智能AI助手，助力企业高效办公",
  },
  {
    path: kq,
    title: "HR考勤数据汇总",
    desc: "实时汇总考勤数据，提升HR管理效率",
  },
  {
    path: sj,
    title: "集团审计管理",
    desc: "全流程审计管理，保障集团运营合规",
  },
]);

const godetailPage = (i: number) => {
  const routes = {
    1: "Exampleitem2",
    2: "Exampleitem",
    3: "Exampleitem3",
    4: "Exampleitem4",
    5: "Exampleitem5",
    6: "Exampleitem6",
  };
  router.push({
    name: routes[i as keyof typeof routes],
  });
};
</script>

<style lang="scss" scoped>
.example {
  background-color: #f3f3f6;
  min-height: 100vh;

  &-banner {
    position: relative;
    height: 100vh;
    background-image: url("@/assets/img/example/bg.png");
    background-size: cover;
    background-position: center;

    &::before {
      content: "";
      position: absolute;
      top: 0;
      left: 0;
      right: 0;
      bottom: 0;
      background-color: rgba(0, 0, 0, 0.3);
    }
  }

  &-content {
    padding: 20px;
  }
}

.banner-content {
  position: relative;
  padding: 20px;
  color: #fff;
  text-align: center;
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 100%;
  z-index: 1;

  h1 {
    font-size: 24px;
    font-weight: bold;
    margin-bottom: 12px;
  }

  h3 {
    font-size: 16px;
  }
}

.cards-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 20px;

  @media (min-width: 768px) {
    grid-template-columns: repeat(3, 1fr);
    max-width: 1200px;
    margin: 0 auto;
    padding: 40px;
  }
}

.example-card {
  background: #fff;
  border-radius: 8px;
  overflow: hidden;
  cursor: pointer;
  transition: transform 0.3s ease;

  &:hover {
    transform: scale(1.05);
  }
}

.card-image-wrapper {
  position: relative;
  width: 100%;
  height: 200px;
  overflow: hidden;

  .card-image {
    width: 100%;
    height: 100%;
  }

  .image-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    padding: 20px;
    background: linear-gradient(
      to bottom,
      rgba(0, 0, 0, 0.6),
      rgba(0, 0, 0, 0)
    );
    color: #fff;
    z-index: 1;

    .overlay-title {
      font-size: 20px;
      font-weight: bold;
      margin-bottom: 8px;
    }

    .overlay-desc {
      font-size: 14px;
    }
  }
}

.card-content {
  padding: 20px;

  .card-title {
    font-size: 18px;
    font-weight: bold;
    color: #333;
    margin-bottom: 8px;
  }

  .card-desc {
    font-size: 14px;
    color: #666;
    line-height: 1.5;
  }
}

.error-block {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  background: #f8f8f8;
  color: #969799;

  p {
    margin-top: 8px;
    font-size: 14px;
  }
}

@media (min-width: 768px) {
  .banner-content {
    text-align: left;
    padding-left: 18%;

    h1 {
      font-size: 35px;
    }

    h3 {
      font-size: 20px;
    }
  }
}
</style>
